home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_lib.arc / PCSETBLK.C < prev    next >
Text File  |  1990-08-09  |  2KB  |  52 lines

  1. /**
  2. *
  3. *  Name         pcsetblk -- Modify an allocated memory block
  4. *
  5. *  Synopsis     ercode = pcsetblk(seg,size,padsize);
  6. *               int ercode        Returned DOS function error code
  7. *               unsigned seg      Segment address of memory block
  8. *               unsigned size     Requested size of the memory block
  9. *               unsigned padsize  Returned adjust memory block size
  10. *
  11. *  Description  pcsetblk adjust the size of the memory block whose
  12. *               segment address is specified in seg.  The block must
  13. *               have been previously allocated either by DOS or by the
  14. *               PCALLOC function.  The size (in paragraphs) of the block
  15. *               is adjusted to the value specified in size.  If a grow
  16. *               request is made which cannot be satisfied, the largest
  17. *               possible expansion is made.
  18. *
  19. *  Returns      ercode            DOS function returned error code
  20. *               padsize           Adjusted size of the block.
  21. *
  22. *  Version      1.0  (C)Copyright Blaise Computing Inc.  1983
  23. *
  24. **/
  25. struct dreg
  26. {
  27.   unsigned ax,bx,cx,dx,si,di,ds,es;
  28. };
  29.  
  30. int pcsetblk(seg,size,padsize)
  31. unsigned seg,size,*padsize;
  32. {
  33.  
  34.     struct dreg dos_reg;
  35.     int ercode,dos();
  36.  
  37.     utinit(&dos_reg);                  /* Initialize registers         */
  38.     dos_reg.ax = 0x4a00;               /* DOS function 4ah             */
  39.     dos_reg.bx = size;
  40.     dos_reg.es = seg;
  41.     ercode     = dos(&dos_reg);
  42.     if (ercode == 8)
  43.        *padsize = dos_reg.bx;
  44.     else if (ercode == 0)
  45.        *padsize = size;
  46.     else
  47.        *padsize = 0;
  48.  
  49.     return(ercode);
  50.  
  51. }
  52.